// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.SnapshotLifecycleManagement;

public sealed partial class SlmConfiguration
{
	/// <summary>
	/// <para>A list of feature states to be included in this snapshot. A list of features available for inclusion in the snapshot and their descriptions be can be retrieved using the get features API.<br/>Each feature state includes one or more system indices containing data necessary for the function of that feature. Providing an empty array will include no feature states in the snapshot, regardless of the value of include_global_state. By default, all available feature states will be included in the snapshot if include_global_state is true, or no feature states if include_global_state is false.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("feature_states")]
	public ICollection<string>? FeatureStates { get; set; }

	/// <summary>
	/// <para>If false, the snapshot fails if any data stream or index in indices is missing or closed. If true, the snapshot ignores missing or closed data streams and indices.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ignore_unavailable")]
	public bool? IgnoreUnavailable { get; set; }

	/// <summary>
	/// <para>If true, the current global state is included in the snapshot.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("include_global_state")]
	public bool? IncludeGlobalState { get; set; }

	/// <summary>
	/// <para>A comma-separated list of data streams and indices to include in the snapshot. Multi-index syntax is supported.<br/>By default, a snapshot includes all data streams and indices in the cluster. If this argument is provided, the snapshot only includes the specified data streams and clusters.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("indices")]
	public Elastic.Clients.Elasticsearch.Serverless.Indices? Indices { get; set; }

	/// <summary>
	/// <para>Attaches arbitrary metadata to the snapshot, such as a record of who took the snapshot, why it was taken, or any other useful data. Metadata must be less than 1024 bytes.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("metadata")]
	public IDictionary<string, object>? Metadata { get; set; }

	/// <summary>
	/// <para>If false, the entire snapshot will fail if one or more indices included in the snapshot do not have all primary shards available.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("partial")]
	public bool? Partial { get; set; }
}

public sealed partial class SlmConfigurationDescriptor : SerializableDescriptor<SlmConfigurationDescriptor>
{
	internal SlmConfigurationDescriptor(Action<SlmConfigurationDescriptor> configure) => configure.Invoke(this);

	public SlmConfigurationDescriptor() : base()
	{
	}

	private ICollection<string>? FeatureStatesValue { get; set; }
	private bool? IgnoreUnavailableValue { get; set; }
	private bool? IncludeGlobalStateValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Indices? IndicesValue { get; set; }
	private IDictionary<string, object>? MetadataValue { get; set; }
	private bool? PartialValue { get; set; }

	/// <summary>
	/// <para>A list of feature states to be included in this snapshot. A list of features available for inclusion in the snapshot and their descriptions be can be retrieved using the get features API.<br/>Each feature state includes one or more system indices containing data necessary for the function of that feature. Providing an empty array will include no feature states in the snapshot, regardless of the value of include_global_state. By default, all available feature states will be included in the snapshot if include_global_state is true, or no feature states if include_global_state is false.</para>
	/// </summary>
	public SlmConfigurationDescriptor FeatureStates(ICollection<string>? featureStates)
	{
		FeatureStatesValue = featureStates;
		return Self;
	}

	/// <summary>
	/// <para>If false, the snapshot fails if any data stream or index in indices is missing or closed. If true, the snapshot ignores missing or closed data streams and indices.</para>
	/// </summary>
	public SlmConfigurationDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true)
	{
		IgnoreUnavailableValue = ignoreUnavailable;
		return Self;
	}

	/// <summary>
	/// <para>If true, the current global state is included in the snapshot.</para>
	/// </summary>
	public SlmConfigurationDescriptor IncludeGlobalState(bool? includeGlobalState = true)
	{
		IncludeGlobalStateValue = includeGlobalState;
		return Self;
	}

	/// <summary>
	/// <para>A comma-separated list of data streams and indices to include in the snapshot. Multi-index syntax is supported.<br/>By default, a snapshot includes all data streams and indices in the cluster. If this argument is provided, the snapshot only includes the specified data streams and clusters.</para>
	/// </summary>
	public SlmConfigurationDescriptor Indices(Elastic.Clients.Elasticsearch.Serverless.Indices? indices)
	{
		IndicesValue = indices;
		return Self;
	}

	/// <summary>
	/// <para>Attaches arbitrary metadata to the snapshot, such as a record of who took the snapshot, why it was taken, or any other useful data. Metadata must be less than 1024 bytes.</para>
	/// </summary>
	public SlmConfigurationDescriptor Metadata(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> selector)
	{
		MetadataValue = selector?.Invoke(new FluentDictionary<string, object>());
		return Self;
	}

	/// <summary>
	/// <para>If false, the entire snapshot will fail if one or more indices included in the snapshot do not have all primary shards available.</para>
	/// </summary>
	public SlmConfigurationDescriptor Partial(bool? partial = true)
	{
		PartialValue = partial;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (FeatureStatesValue is not null)
		{
			writer.WritePropertyName("feature_states");
			JsonSerializer.Serialize(writer, FeatureStatesValue, options);
		}

		if (IgnoreUnavailableValue.HasValue)
		{
			writer.WritePropertyName("ignore_unavailable");
			writer.WriteBooleanValue(IgnoreUnavailableValue.Value);
		}

		if (IncludeGlobalStateValue.HasValue)
		{
			writer.WritePropertyName("include_global_state");
			writer.WriteBooleanValue(IncludeGlobalStateValue.Value);
		}

		if (IndicesValue is not null)
		{
			writer.WritePropertyName("indices");
			JsonSerializer.Serialize(writer, IndicesValue, options);
		}

		if (MetadataValue is not null)
		{
			writer.WritePropertyName("metadata");
			JsonSerializer.Serialize(writer, MetadataValue, options);
		}

		if (PartialValue.HasValue)
		{
			writer.WritePropertyName("partial");
			writer.WriteBooleanValue(PartialValue.Value);
		}

		writer.WriteEndObject();
	}
}